use std::collections::HashSet;

fn parse_input() -> Vec<char> {
    include_str!("../input.txt").chars().collect()
}

fn part1() {
    let datastream = parse_input();

    for end in 3..datastream.len() {
        let begin = end - 3;
        let chars = &datastream[begin..=end]
            .into_iter()
            .map(|c| -> char { c.clone() })
            .collect::<HashSet<char>>();
        if chars.len() == 4 {
            println!("Part 1: {}", end + 1);
            return;
        }
    }

}

fn part2() {
    let datastream = parse_input();

    for end in 13..datastream.len() {
        let begin = end - 13;
        let chars = &datastream[begin..=end]
            .into_iter()
            .map(|c| -> char { c.clone() })
            .collect::<HashSet<char>>();
        if chars.len() == 14 {
            println!("Part 2: {}", end + 1);
            return;
        }
    }
}

fn main() {
    part1();
    part2();
}
